perm filename A105.TEX[106,RWF] blob
sn#834033 filedate 1987-02-09 generic text, type C, neo UTF8
COMMENT ā VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 \magnification\magstephalf
C00006 ENDMK
Cā;
\magnification\magstephalf
\input macro.tex
\def\today{\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi
\space\number\day, \number\year}
\baselineskip 14pt
\rm
\line{\sevenrm a105.tex[106,phy] \today\hfill}
\font\rmn=cmr9
{\rmn
{\narrower\smallskip\noindent
{\bf Solution to p07.pgo}
{\obeylines\obeyspaces\let =\ \tt
PROGRAM PolyDiv (INPUT, OUTPUT);
CONST Big=1000000.0;
Max=20;
TYPE Poly=ARRAY[0..Max] of REAL;
VAR I,J,M,N,D: INTEGER;
Q,R,B: Poly;
PROCEDURE ReadPoly (VAR L: INTEGER; VAR P: Poly);
BEGIN
L:=0;
READ (P[L]);
WHILE ABS (P[L])<Big DO
BEGIN
WRITELN (L,P[L]);
L:=L+1;
READ (P[L])
END;
L:=L-1
END;
BEGIN (* main *)
ReadPoly (M,R);
ReadPoly (N,B);
FOR I:=M-N DOWNTO 0 DO (* I IS SHIFT *)
(* GET Q[I] *)
BEGIN
Q[I]:=R[I+N]/B[N];
FOR J:=0 TO N-1 DO
R[J+I]:=R[J+I]-B[J]*Q[I];
R[I+N]:=0.0
END;
FOR I:=0 TO M-N DO
WRITELN (I,Q[I]P;
(* Find high order coefficient *)
D:=N-1;
WHILE (R[D]=0) AND (D>0) DO
D:=D-1;
FOR I:=0 TO D DO
WRITELN (I,R[I])
END.
}
\vfill\eject
{\obeylines\obeyspaces\let =\ \tt
0 4.000000E+00
1 6.000000E+00
2 1.000000E+01
3 1.000000E+01
4 5.000000E+00
5 1.000000E+00
0 1.000000E+00
1 2.000000E+00
2 1.000000E+00
0 1.000000E+00
1 3.000000E+00
2 3.000000E+00
3 1.000000E+00
0 3.000000E+00
1 1.000000E+00
}
\smallskip}
}
\bigskip
\line{\copyright 1984 Robert W. Floyd; \hfil}
%First draft (not published) ??\hfil}
%revised: Date; subsequently revised.\hfill}
\bye